﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cloud.Model;
using Cloud.BLL;



public partial class Three_Managerment_P0502_P_zhuanban : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (IsPostBack)
            {

            }
            else
            {
                this.bm_drop.DataSource = DWManager.Sanji(((USER_INFO)Session["users"]).DEPARTMENT);
                this.bm_drop.DataTextField = "DWMC";
                this.bm_drop.DataValueField = "DWBH";
                this.bm_drop.DataBind();
                int id = Convert.ToInt32(Request.QueryString["id"]);
                Problem activity = ProblemManager.FindById(id);
                this.sjid.Value = activity.Appealid.ToString();
                this.times.Value = activity.Regtime.ToString();
                int currentDay = Convert.ToInt32(DateTime.Now.DayOfWeek);
                if (currentDay == 6)
                {
                    this.xbsj.Value = DateTime.Now.AddDays(4).ToString();
                }
                else if (currentDay == 0 || currentDay == 1 || currentDay == 2)
                {
                    this.xbsj.Value = DateTime.Now.AddDays(3).ToString();
                }
                else
                {
                    this.xbsj.Value = DateTime.Now.AddDays(5).ToString();
                }
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void Send_Click(object sender, EventArgs e)
    {
        try
        {

            if (this.xbsj.Value.Equals(""))
            {
                Response.Write("<script>alert('请选择时间'); </script>");
                return;
            }


            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            int id = Convert.ToInt32(Request.QueryString["id"]);
            Problem_zhuanban activity = new Problem_zhuanban();
            Problem a1 = ProblemManager.FindById(id);
            activity.Appeal_email = a1.Appeal_email;
            activity.Appeal_name = a1.Appeal_name;
            activity.Appeal_tel = a1.Appeal_tel;
            activity.Appeal_type_id = a1.Appeal_type_id;
            activity.Appealid = a1.Appealid;
            activity.Ascription_id = a1.Ascription_id;
            activity.Context = a1.Context;
            activity.Db_num = a1.Db_num;
            activity.Emergencys = a1.Emergencys;
            activity.Handle_type = 0;
            activity.Important = a1.Important;
            activity.Ischeck = a1.Ischeck;
            activity.Islook0 = a1.Islook0;
            activity.Islook1 = a1.Islook1;
            activity.Islook2 = a1.Islook2;
            activity.Jobnum = a1.Jobnum;
            activity.Mp3url = a1.Mp3url;
            activity.Opens = a1.Opens;
            activity.Regtime = a1.Regtime;
            activity.Reject_num = a1.Reject_num;
            activity.Repeats = a1.Repeats;
            activity.Satisfied = a1.Satisfied;
            activity.Secrecy = a1.Secrecy;
            activity.Source_id = a1.Source_id;
            activity.Title = a1.Title;
            activity.Xialei = a1.Xialei;
            activity.Zbtime = new DateTime(1900, 01, 01, 00, 00, 00);
            activity.Current_ld = 2;
            activity.Zrdwid = this.bm_drop.SelectedItem.Value;
            activity.Bldwid = "";
            activity.Bm2_type = 9;
            activity.Bm1_type = 0;
            activity.Xbtime = Convert.ToDateTime(xbsj.Value);
            if (Problem_zhuanbanManager.Save(activity) > 0)
            {
                Problem_historic2 his = new Problem_historic2();
                his.Blyj = this.con.Value;
                his.Title = ((USER_INFO)Session["users"]).USER_NAME + "  转派 ";
                his.Bm2 = bm_drop.SelectedItem.Value;
                his.Evente = 1;
                his.Idopen = this.sjid.Value;


                his.Bm1 = ((USER_INFO)Session["users"]).DEPARTMENT;
                his.Item1 = 0;
                his.Item2 = "";
                his.Item3 = "";
                his.Name = ((USER_INFO)Session["users"]).USER_NAME;
                his.Times = DateTime.Now;
                his.Timese = Convert.ToDateTime(xbsj.Value);
                // 04一级部门  05二级   06 三级

                Problem_historic2Manager.Save(his);
                Response.Write("<script>alert('转派成功！');location.href='List_dbj.aspx'</script>");
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
}